package com.lagou.ex.mybatis.util;

import java.util.UUID;

public final class IdUtil {
    private static final SnowFlakeIdWorker SNOW_FLAKE_ID_WORKER = new SnowFlakeIdWorker(1);

    /**
     * 生成id
     *
     * @return id
     */
    public static String generate() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    /**
     * 使用雪花算法生成一个id
     *
     * @return id
     */
    public static Long generateBySnow() {
        return SNOW_FLAKE_ID_WORKER.nextId();
    }

}
